package com.shop.dao.impl;

import com.shop.dao.BaseOrderDao;
import com.shop.dao.OrderInfoDao;
import com.shop.dao.base.BaseDao;
import com.shop.entity.BaseOrder;
import com.shop.entity.OrderInfo;

import java.sql.SQLException;
import java.time.LocalDateTime;

/**
 * @Description TODO
 * @Author hyl
 * @Date 2022/3/16 11:50
 **/
public class BaseOrderDaoImpl extends BaseDao<BaseOrder> implements BaseOrderDao {
	@Override
	public int add(BaseOrder order){
		String sql = "insert into t_base_order(user_id\n" +
				",account\n" +
				",user_address\n" +
				",create_time\n" +
				",amount\n" +
				",order_no\n) values(?,?,?,?,?,?)";
		Object[] params ={order.getUserId(),
				order.getAccount(),
				order.getUserAddress(),
				LocalDateTime.now(),
				order.getAmount(),
				order.getOrderNo()};
		try {
			return super.executeUpdate(sql, params);
		} catch (SQLException throwables) {
			throwables.printStackTrace();
		}
		return 0;
	}
}
